package com.yima.baseproj.utils.wx.weapp.model;

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用于处理和存储微信小程序中的用户电话信息
 */
@NoArgsConstructor
@Data
public class UserPhoneModel {

    @SerializedName("errcode")
    private Integer errcode;
    @SerializedName("errmsg")
    private String errmsg;
    @SerializedName("phone_info")
    private PhoneInfoDTO phoneInfo;

    public static UserPhoneModel objectFromData(String str) {

        return new Gson().fromJson(str, UserPhoneModel.class);
    }

    @NoArgsConstructor
    @Data
    public static class PhoneInfoDTO {
        @SerializedName("phoneNumber")
        private String phoneNumber;
        @SerializedName("purePhoneNumber")
        private String purePhoneNumber;
        @SerializedName("countryCode")
        private Integer countryCode;
        @SerializedName("watermark")
        private WatermarkDTO watermark;

        public static PhoneInfoDTO objectFromData(String str) {

            return new Gson().fromJson(str, PhoneInfoDTO.class);
        }

        @NoArgsConstructor
        @Data
        public static class WatermarkDTO {
            @SerializedName("timestamp")
            private Integer timestamp;
            @SerializedName("appid")
            private String appid;

            public static WatermarkDTO objectFromData(String str) {

                return new Gson().fromJson(str, WatermarkDTO.class);
            }
        }
    }
}
